import type { SopDocAppModel } from '#/api/devOperation/sop/model/sopDocAppModel';
import type { SopDocInfoModel } from '#/api/devOperation/sop/model/sopDocInfoModel';

import { requestClient } from '#/api/request';
import { ServicePrefixEnum } from '#/enums/commonEnum';
import { ContentTypeEnum } from '#/enums/httpEnum';

const ServicePrefix = ServicePrefixEnum.SOPADMIN;

export namespace SopOpenApi {
  /**
   *
   */
  export async function findAppList() {
    return requestClient.get<SopDocAppModel.SopDocAppResultVO[]>(
      `${ServicePrefix}/anyTenant/website/app/list`,
    );
  }

  /**
   *
   */
  export async function findDocTree(docAppId: string) {
    return requestClient.get<SopDocInfoModel.SopDocInfoResultVO[]>(
      `${ServicePrefix}/anyTenant/website/doc/tree`,
      {
        params: { docAppId },
        headers: {
          'Content-Type': ContentTypeEnum.FORM_URLENCODED,
        },
      },
    );
  }

  /**
   *
   */
  export async function getDocDetail(id: string) {
    return requestClient.get<SopDocInfoModel.DocInfoViewVO>(
      `${ServicePrefix}/anyTenant/website/doc/detail`,
      {
        params: { id },
        headers: {
          'Content-Type': ContentTypeEnum.FORM_URLENCODED,
        },
      },
    );
  }
}
